<?php
class ModelDelimanHanhdong extends Model 
{
	public function getList($where = "")
	{
		$query = $this->db->query("Select `dlm_hanhdong`.* from `dlm_hanhdong` where 1=1 ".$where);
		return $query->rows;
	}
	
	public function getItem($hanhdongid)
	{
		$query = $this->db->query("Select * from `dlm_hanhdong` where hanhdongid = '".$hanhdongid."'");
		return $query->row;
	}
		
	public function insert($data)
	{
		$hanhdongid=$this->db->escape(@$data['hanhdongid']);
		$chucnangid=$this->db->escape(@$data['chucnangid']);
		$mahanhdong=$this->db->escape(@$data['mahanhdong']);
		$tenhanhdong=$this->db->escape(@$data['tenhanhdong']);
				
		$field=array(
						'hanhdongid',
						'chucnangid',
						'mahanhdong',
						'tenhanhdong'
					);
		$value=array(
						$hanhdongid,
						$chucnangid,
						$mahanhdong,
						$tenhanhdong
					);
		return $this->db->insertData("dlm_hanhdong",$field,$value);
	}
	
	public function update($data)
	{
		$hanhdongid=$this->db->escape(@$data['hanhdongid']);
		$chucnangid=$this->db->escape(@$data['chucnangid']);
		$mahanhdong=$this->db->escape(@$data['mahanhdong']);
		$tenhanhdong=$this->db->escape(@$data['tenhanhdong']);
				
		$field=array(
						'hanhdongid',
						'chucnangid',
						'mahanhdong',
						'tenhanhdong'
					);
		$value=array(
						$hanhdongid,
						$chucnangid,
						$mahanhdong,
						$tenhanhdong
					);
					
		$where="hanhdongid = '".$hanhdongid."'";
		$this->db->updateData("dlm_hanhdong",$field,$value,$where);
	}	
			
	public function delete($hanhdongid)
	{
		$hanhdongid=$this->db->escape(@$hanhdongid);
		$where="hanhdongid = '".$hanhdongid."'";
		$this->db->deleteData('dlm_hanhdong',$where);
	}
	
	public function deletes($data)
	{
		foreach($data as $hanhdongid)
		{
			$this->delete($hanhdongid);
		}		
	}	
}

?>